calculating the number of factors